package com.hckjsec.system.controller;

import java.util.List;

import com.hckjsec.common.utils.uuid.IdWorker;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hckjsec.common.annotation.Log;
import com.hckjsec.common.core.controller.BaseController;
import com.hckjsec.common.core.domain.AjaxResult;
import com.hckjsec.common.enums.BusinessType;
import com.hckjsec.system.domain.WorkOaCwa;
import com.hckjsec.system.service.IWorkOaCwaService;
import com.hckjsec.common.utils.poi.ExcelUtil;
import com.hckjsec.common.core.page.TableDataInfo;

/**
 * 考勤主Controller
 * 
 * @author cyt
 * @date 2021-06-26
 */
@RestController
@RequestMapping("/work/cwa")
public class WorkOaCwaController extends BaseController
{
    @Autowired
    private IWorkOaCwaService workOaCwaService;

    /**
     * 查询考勤主列表
     */
    @PreAuthorize("@ss.hasPermi('system:cwa:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkOaCwa workOaCwa)
    {
        startPage();
        List<WorkOaCwa> list = workOaCwaService.selectWorkOaCwaList(workOaCwa);
        return getDataTable(list);
    }

    /**
     * 导出考勤主列表
     */
    @PreAuthorize("@ss.hasPermi('system:cwa:export')")
    @Log(title = "考勤", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorkOaCwa workOaCwa)
    {
        List<WorkOaCwa> list = workOaCwaService.selectWorkOaCwaList(workOaCwa);
        ExcelUtil<WorkOaCwa> util = new ExcelUtil<WorkOaCwa>(WorkOaCwa.class);
        return util.exportExcel(list, "cwa");
    }

    /**
     * 获取考勤主详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cwa:query')")
    @GetMapping(value = "/{cwaId}")
    public AjaxResult getInfo(@PathVariable("cwaId") Long cwaId)
    {
        return AjaxResult.success(workOaCwaService.selectWorkOaCwaById(cwaId));
    }

    /**
     * 新增考勤主
     */
    @PreAuthorize("@ss.hasPermi('system:cwa:add')")
    @Log(title = "考勤", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkOaCwa workOaCwa)
    {
        return toAjax(workOaCwaService.insertWorkOaCwa(workOaCwa));
    }

    /**
     * 修改考勤主
     */
    @PreAuthorize("@ss.hasPermi('system:cwa:edit')")
    @Log(title = "考勤", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkOaCwa workOaCwa)
    {
        return toAjax(workOaCwaService.updateWorkOaCwa(workOaCwa));
    }

    /**
     * 删除考勤主
     */
    @PreAuthorize("@ss.hasPermi('system:cwa:remove')")
    @Log(title = "考勤主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cwaIds}")
    public AjaxResult remove(@PathVariable Long[] cwaIds)
    {
        return toAjax(workOaCwaService.deleteWorkOaCwaByIds(cwaIds));
    }
}
